/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 *
 * @author Rodrigo
 */


public class ImagePanel extends JPanel {

	  private Image img;
	  private int mode;
	  private Dimension size;
	
	  public ImagePanel(String img, int mode) {
	    this(new ImageIcon(img).getImage(), mode);
	  }
	
	  public ImagePanel(Image img, int mode) {
	    this.img = img;
	    this.mode = mode;
	    
	    size = new Dimension(img.getWidth(null), img.getHeight(null));
	    
	    setPreferredSize(size);
	    setMinimumSize(size);
	    setMaximumSize(size);
	    setSize(size);
	    setLayout(null);
	  }
	
	  @Override
	  public void paintComponent(Graphics g) {
	    //g.drawImage(img, 0, 0, null);
	    
	    int x = 0;
	    int y = 0;
		
	    while (x < this.getWidth()) {
	        
	        y=0;
	        
	        while (y < this.getHeight()){				
	            g.drawImage(img,x, y, null);					       				
	            y += size.height;					       
	         }  
	         x += size.width;
	    }
	    
	    
	  }

}

